const npsUtils = require('nps-utils'); // not required, but handy!

const {
  // series,
  // rimraf,
  concurrent,
} = npsUtils;

module.exports = {
  scripts: {
    start: {
      description: 'yarn start',
      script: 'node ./bin/www',
      prod: {
        description: 'yarn start production',
        script: 'cross-env NODE_ENV=production node ./bin/www',
      },
    },
    dev: {
      default: {
        description: 'nodemon',
        script: 'cross-env NODE_ENV=development nodemon ./bin/www',
      },
    },
    lint: {
      default: {
        description: 'eslint检查Error',
        script: 'eslint .',
      },
      fix: {
        description: 'eslint检查并修复Error',
        script: 'eslint . --fix',
      },
    },
    apidoc: {
      default: {
        description: 'Document generation through apidoc',
        script: 'apidoc -i routes/ -o public/doc',
      },
    },
    /* *************** */
    pm2: {
      default: {
        // https://www.npmjs.com/package/pm2
        description: 'pm2',
        script: 'pm2 start ecosystem.config.js --env production',
      },
      runtime: {
        description: 'pm2',
        script: 'pm2-runtime start ecosystem.config.js --env production',
      },
    },
    debug: {
      default: 'cross-env NODE_ENV=development nodemon ./bin/www --debug',
    },
    test: {
      default: 'cross-env NODE_ENV=test babel-tape-runner test/test-*.js',
      // learn more about Jest here: https://facebook.github.io/jest 未配置jest
      watch: {
        description: 'run in the amazingly intelligent Jest watch mode',
        script: 'jest --watch',
      },
    },
    build: {
      // learn more about Webpack here: https://webpack.js.org/
      default: 'webpack',
      prod: 'webpack -p',
    },
    // learn more about npsUtils here: `https://npm.im/nps-utils or https://www.npmjs.com/package/nps-utils`
    validate: concurrent.nps('lint', 'test', 'build'),
  },
  // 日志级别[error | warn | info(default)]
  // logLevel: ,
};
